#include "MovableObject.h"

namespace DreamEngine
{
CMatrix16 CMovableObject::m_defaultTrans;

CMovableObject::CMovableObject(CRenderSystem* pRenderSystem, const CString& name):
	m_name(name),
	m_pRenderSystem(pRenderSystem),
	m_pSceneNode(MATH_NULL),
	m_trangleCount(0)
{

}


CMovableObject::~CMovableObject(void)
{
}

void CMovableObject::Attach(CSceneNode* pNode)
{
	m_pSceneNode = pNode;
}

const CMatrix16& CMovableObject::GetWorldTransform()const
{
	if (m_pSceneNode != MATH_NULL)
	{
		return m_pSceneNode->GetDerivedWorldMatrix();
	}
	else
	{
		return m_defaultTrans;
	}
}

m_uint16 CMovableObject::CaculateTrangleCount()
{
	m_uint16 trangleCount = 0;
	for (RenderDataLst::const_iterator iter=m_renderData.begin();
		 iter != m_renderData.end(); ++iter)
	{
		trangleCount += (*iter)->CaculateTrangleCount();
	}
	
	return trangleCount;
}

}
